#映射(mapping)机制用于进行字段类型确认，将每个字段匹配为一种确定的数据类型(string, number, booleans, date等)
#包含索引、字段、分析器等内容的定义
#核心简单字段类型
    类型                    表示的数据类型
    text	                text
    Whole number	        byte, short, integer, long
    Floating point	        float, double
    Boolean	                boolean
    Date	                date
    ip                      ip地址

#查看映射
    GET /gb/_mapping/tweet

#更新映射,向已有映射中增加字段，但你不能修改它
    DELETE /gb
    PUT /gb
    {
      "mappings": {
        "tweet" : {
          "properties" : {
            "tweet" : {
              "type" :    "string",
              "analyzer": "english"
            },
            "date" : {
              "type" :   "date"
            },
            "name" : {
              "type" :   "string"
            },
            "user_id" : {
              "type" :   "long"
            }
          }
        }
      }
    }

    #新字段合并至存在的那个映射
    PUT my_index/_mapping/my_ip
    {
      "properties" : {
        "tag" : {
          "type" :    "text",
          "index":    "false"
        }
      }
    }

#内部对象的映射
    #内部对象的映射
    {
        "tweet":            "Elasticsearch is very flexible",
        "user": {
            "id":           "@johnsmith",
            "gender":       "male",
            "age":          26,
            "name": {
                "full":     "John Smith",
                "first":    "John",
                "last":     "Smith"
            }
        }
    }
    #内部对象的映射--->映射成简单关系
    {
        "tweet":            [elasticsearch, flexible, very],
        "user.id":          [@johnsmith],
        "user.gender":      [male],
        "user.age":         [26],
        "user.name.full":   [john, smith],
        "user.name.first":  [john],
        "user.name.last":   [smith]
    }

    #内部对象数组
    {
        "followers": [
            { "age": 35, "name": "Mary White"},
            { "age": 26, "name": "Alex Jones"},
            { "age": 19, "name": "Lisa Smith"}
        ]
    }
    #内部对象数组---->映射成简单关系
    {
        "followers.age":    [19, 26, 35],
        "followers.name":   [alex, jones, lisa, smith, mary, white]
    }
    #是否有26岁的追随者且名字叫Alex Jones,关联内部对象可解决此类问题

#分析器(analyzer)只是一个包装用于将三个功能放到一个包里：字符过滤器，分词器，标记过滤
#测试分析器
    POST /_analyze
    {
      "analyzer": "standard",
      "text": "Text to analyze"
    }

#使用过滤器过滤分词
    POST _analyze
    {
      "tokenizer": "standard",
      "filter":  [ "lowercase", "asciifolding" ],
      "text":      "Is this déja vu?"
    }

#创建自定义分析器,过滤html字符，大写转小写
    PUT /my_index
    {
        "settings": {
            "analysis": {
                "char_filter": {
                    "&_to_and": {
                        "type":       "mapping",
                        "mappings": [ "&=> and "]
                }},
                "filter": {
                    "my_stopwords": {
                        "type":       "stop",
                        "stopwords": [ "the", "a" ]
                }},
                "analyzer": {
                    "my_analyzer": {
                        "type":         "custom",
                        "char_filter":  [ "html_strip", "&_to_and" ],
                        "tokenizer":    "standard",
                        "filter":       [ "lowercase", "my_stopwords" ]
                }}
    }}}

    #测试分词效果
    GET /my_index/_analyze?analyzer=my_analyzer
    The quick & brown fox

    #应用在一个 string 类型的字段上
    PUT /my_index/_mapping/my_type
    {
        "properties": {
            "title": {
                "type":      "text",
                "analyzer":  "my_analyzer"
            }
        }
    }


    #全局使用空格分词
    PUT /my_index/my_type/_mapping
    {
        "my_type": {
        "_all": { "analyzer": "whitespace" }
        }
    }

    #在具体的字段，不使用分词，配合上面使用
    PUT /my_index/_mapping/my_type
    {
        "properties": {
            "title": {
                "type":      "text",
                "analyzer":  "not_analyzed"
            }
        }
    }